//
//  YHSearchResultViewController.m
//  FAKER
//
//  Created by dllo on 15/11/8.
//  Copyright © 2015年 YHLai. All rights reserved.
//

#import "YHSearchResultViewController.h"
#import "FitHeader.h"
#import "BaseClassWebView.h"

//搜索结果
#define SEARCHRESULT_URLSTRING [NSString stringWithFormat:@"http://search.myzaker.com/api/?_appid=iphone&keyword=%@", _searchKeyword]

@interface YHSearchResultViewController ()<UIWebViewDelegate>
@property(nonatomic, strong)BaseClassWebView *webView;
@end

@implementation YHSearchResultViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    self.title = @"搜索结果";
}

- (void)loadView
{
    [super loadView];
    _webView = [[BaseClassWebView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT - 64)];
    _webView.delegate = self;
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:[SEARCHRESULT_URLSTRING stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLQueryAllowedCharacterSet]]]]];
    [self.view addSubview:_webView];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    if (NSUSERDEFAULTS_NIGHT) {
        [_webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.background='#1F2121'"];
        [_webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByTagName('body')[0].style.webkitTextFillColor='gray'"];
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
